set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/3rdParty )
find_package(openssl REQUIRED)
find_package(crypto REQUIRED)
find_package(sqlite3 REQUIRED)

include_directories( ${PROJECT_SOURCE_DIR}/PopupLibOSAL/include )
include_directories( ${PROJECT_SOURCE_DIR}/PopupDatabaseSqlite/include )
include_directories( ${PROJECT_SOURCE_DIR}/PopupLibrary/include )

file( GLOB sources *.h *.c *.hpp *.cpp )
add_executable( PopupServer ${sources} )

target_link_libraries( PopupServer popup-static osal-static database-static ${crypto_LIBRARY} ${openssl_LIBRARY} ${sqlite3_LIBRARY} )

# Windows specific
if (${CMAKE_SYSTEM_NAME} STREQUAL Windows)
find_package(pthread REQUIRED)
include_directories( ${pthread_INCLUDE_DIRS} )
target_link_libraries( PopupServer ${pthread_LIBRARY} ws2_32 )
endif (${CMAKE_SYSTEM_NAME} STREQUAL Windows)

# Linux specific
if (${CMAKE_SYSTEM_NAME} STREQUAL Linux)
target_link_libraries( PopupServer dl pthread ) 
endif (${CMAKE_SYSTEM_NAME} STREQUAL Linux)

install( TARGETS PopupServer DESTINATION ${POPUP_INSTALL_DIR}/bin )
